<?php
namespace Home\Controller;
use Common\Controller\UserBaseController;
/**
 * 首页控制器
 */
class LastresultController extends UserBaseController{
	 
	/**
	 *  
	 */
	public function index(){
		$c_type=$_GET['lottery'];
		$w_time=$_GET['-'];
		$data=array();
		 header('Content-type:text/json');
		 switch ($c_type)
		  {
			  //香港六合彩
 		   case 'HK6':  //香港六合彩 彩种id 12
		   $condition['c_id']=12;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='HK6';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;
		//幸运飞艇
 		   case 'XYFT':  //幸运飞艇 彩种id 5
		   $condition['c_id']=5;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='XYFT';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;
			//北京PK10
 		   case 'BJPK10':  //北京PK10 彩种id 4
		   $condition['c_id']=4;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='BJPK10';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break; 
		  //重庆时时彩
 		   case 'CQSSC':  //重庆时时彩 彩种id 1
		   $condition['c_id']=1;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='CQSSC';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;	
			//新疆时时彩
 		   case 'XJSSC':  //新疆时时彩 彩种id 2
		   $condition['c_id']=2;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='XJSSC';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;     
		//天津时时彩
 		   case 'TJSSC':  //天津时时彩 彩种id 3
		   $condition['c_id']=3;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='TJSSC';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;  	  
			//重庆幸运农场
 		   case 'XYNC':  //重庆幸运农场 彩种id　８
		   $condition['c_id']=8;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='XYNC';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break; 
		//广东快乐十分
 		   case 'GDKLSF':  //广东快乐十分 彩种id　6
		   $condition['c_id']=6;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='GDKLSF';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;
		  //广西快三
 		   case 'GXK3':  //广西快三 彩种id 7
		   $condition['c_id']=7;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='GXK3';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;
		//PC蛋蛋
 		   case 'PCEGG':   //PC蛋蛋 彩种id 11
		   $condition['c_id']=11;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='PCEGG';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;
		//北京快8
 		   case 'BJKL8':   //北京快8 彩种id 9
		   $condition['c_id']=9;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='BJKL8';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;
		//广西快乐十分
 		   case 'GXKLSF':    //广西快乐十分 彩种id 10
		   $condition['c_id']=10;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='GXKLSF';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;
		//分分彩
 		   case 'FFC':    //分分彩 彩种id 13
		   $condition['c_id']=13;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='FFC';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;	
			  	  break;
		//QQ分分彩
 		   case 'QQFFC':    //QQ分分彩 彩种id 16
		   $condition['c_id']=16;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='QQFFC';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;
			  //QQ分分彩
 		   case 'TXFFC':    //QQ分分彩 彩种id 16
		   $condition['c_id']=17;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='TXFFC';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;
			  //加拿大快乐8
 		   case 'JNDKL8':   //加拿大 彩种id 15
		   $condition['c_id']=15;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='JNDKL8';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;  
			  	  //加拿大3.5
 		   case 'JND':   //加拿大 彩种id 24
		   $condition['c_id']=24;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='JND';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;  
			  //河北快三
 		   case 'HEBK3':  //河北快三 彩种id 19
		   $condition['c_id']=19;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='HEBK3';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;	
			  //湖北快三
 		   case 'HUBK3':  //湖北快三 彩种id 18
		   $condition['c_id']=18;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='HUBK3';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;
			  //江苏快三
 		   case 'JSK3':  //江苏快三 彩种id 20
		   $condition['c_id']=20;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='JSK3';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;	
			  	  //上海时时乐
 		   case 'SHSSL':  //上海时时乐 彩种id 21
		   $condition['c_id']=21;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='SHSSL';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;
			  	  //台湾宾果
 		   case 'TWBG':  //台湾宾果 彩种id 22
		   $condition['c_id']=22;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='TWBG';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;  	
			    //台湾五分
 		   case 'TWWF':  //台湾五分 彩种id 23
		   $condition['c_id']=23;
			  $result=M('lottery_results')->where($condition)->Order('id desc')->limit(1)->find();
			  
			     $data['lottery']='TWWF';
				 $data['drawNumber']=$result['c_no'];
				 $data['result']=$result['lottery_result'];
				 $data['detail']=$result['detail']; 
				 $data['resultOther']=$result['lm'];
			 
			  echo json_encode($data);exit(0);
			  break;

		  default:echo json_encode($data);exit(0);
                break;
		    
		  }
		
		 
	} 

 public function account(){
	
	 $time=strtotime(date('Y-m-d'));
	  $lost=M('lottery_order')->where("m_id=".$_SESSION['member_id']." and add_time>".$time)->sum('lost_money');
	  $win=M('lottery_order')->where("m_id=".$_SESSION['member_id']." and add_time>".$time)->sum('win_money');
	  $data['result']=$win-$lost;
	  echo $data['result'];exit(0);
	
  }
 

}
